package jmd.parse;

import java.nio.ByteBuffer;
import java.nio.charset.Charset;

/**
 * 
 * @author Administrator
 * 
 */
public class ParseImpl implements Parse
{

	String content = "";
	String[] pros;
	String[] clentString;

	/**
	 * this function is used to decode the string which is sended from the server.
	 * firstly decode the sentence based on ";" secondly decode the word based on
	 * "," from the first sentence then return the words which we put them into a
	 * string array
	 */
	@Override
	public String[] decodeProtocol(ByteBuffer r_buffer)
	{
		Charset charset = Charset.forName("UTF-8");
		content += charset.decode(r_buffer);
		clentString = content.split(";");
		if (clentString[0].equals("") || " ".trim().equals(clentString[0]))
		{
			pros = null;
		} else
		{
			pros = clentString[0].split(",");
		}
		content = "";
		return pros;
	}

}
